const mongoose = require('mongoose')
//链接mongo 并且使用imooc这个集合
const DB_URL = "mongodb://localhost:27017/baby"
mongoose.connect(DB_URL, { useNewUrlParser: true })

const models = {
    user: {
        "user": { "type": String, require: true },
        "pwd": { "type": String, require: true },
        "time": { "type": String, require: true },
    }
}

for (let m in models) {
    mongoose.model(m, new mongoose.Schema(models[m]))
}

module.exports = {
    getModel: function (name) {
        return mongoose.model(name)
    }
}